<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>商之联运营商后台</title>
  <meta name="description" content="这是一个form页面">
  <meta name="keywords" content="form">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="{:C('SUPPLIER_ADMIN_IMAGE')}favicon.png"> <link rel="apple-touch-icon-precomposed" href="{:C('SUPPLIER_ADMIN_IMAGE')}app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="{:C('SUPPLIER_ADMIN_CSS')}amazeui.min.css"/>
  <link rel="stylesheet" href="{:C('SUPPLIER_ADMIN_CSS')}admin.css">
  <script src="{:C('SUPPLIER_ADMIN_JS')}/laydate/laydate.js"></script>
  <style>
html{background-color:#E3E3E3; font-size:14px; color:#000; font-family:'微软雅黑'}
h2{line-height:30px; font-size:20px;}
a,a:hover{ text-decoration:none;}
pre{font-family:'微软雅黑'}
.box{width:970px; padding:10px 20px; background-color:#fff; margin:10px auto;}
.box a{padding-right:20px;}
</style>
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->
<!-- header start-->

<include file="Public:header"/>

<!-- header end-->

<div class="am-cf admin-main">
  <!-- sidebar start -->
     <include file="Public:menu"/>
  <!-- sidebar end -->

<!-- content start -->
<div class="admin-content">

  <div class="am-cf am-padding">
    <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">活动管理</strong> / <small>添加活动</small></div>
  </div>

  <div class="am-tabs am-margin" data-am-tabs>
    <ul class="am-tabs-nav am-nav am-nav-tabs">
      <!-- <li class="am-active"><a href="#tab1">企业基本信息</a></li> -->
      <li><a href="#tab2">活动信息</a></li>
    </ul>
    <form action="{:U('Activity/edit',array('id'=>$_GET['id']))}" method="post"  enctype="multipart/form-data">
    <div class="am-tabs-bd">
     

      <div class="am-tab-panel am-fade" id="tab2">
        
          <div class="am-g am-margin-top">
            <div class="am-u-sm-4 am-u-md-2 am-text-right">
            活动主题:
            </div>
            <div class="am-u-sm-8 am-u-md-10">
              <input type="text" class="am-input-sm" name="theme" value="{$re.theme}" required onblur="unique();" > <span style="color:red">*必填</span> 
            </div>
          
          </div>

         <div class="am-g am-margin-top">
        <div class="am-u-sm-4 am-u-md-2 am-text-right">
         开始时间:
        </div>
        <div class="am-u-sm-8 am-u-md-10">
         <input name="opentime" class="laydate-icon am-input-sm"  id="start" value="<?php echo date("Y-m-d-h:i:s",$re['opentime']);?>" required style="width:211px; margin-right:10px;height:2.2rem"><span style="color:red">*必填</span> 
        </div>
               </div> 
         <div class="am-g am-margin-top">
           <div class="am-u-sm-4 am-u-md-2 am-text-right">
             结束时间:
           </div>
           <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
            <input name="endtime" class="laydate-icon " required id="end"value="<?php echo date("Y-m-d-h:i:s",$re['endtime']);?>" style="width:211px; margin-right:10px;height:2.2rem" ><span style="color:red">*必填</span> 
           </div>
         </div> 
         <div class="am-g am-margin-top">
            <div class="am-u-sm-4 am-u-md-2 am-text-right">
              活动状态:
            </div>
            <div class="am-u-sm-8 am-u-md-10">
              <select  name="state"  required>
                    <option ><if condition="$re['state'] eq 0">开启状态<else/>关闭状态</if></option>
                    <option value="0" name="state">开启状态</option>
                       <option value="1" name="sate">关闭状态</option>
                       <option value="2" name="sate">结束活动</option>
                </select>
            </div>
         
          </div>
         


                <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">活动图</div>
          <div class="am-u-sm-10">
           <div class="am-form-group">

                      <input name='activityimg' id='fileup' onchange="previewImage(this)" type="file">
                      <if condition="$re['activityimg'] neq '' ">
                    <img id="imghead" src="{$re['activityimg']}" ><else/>
                    <img id="imghead" src="__PUBLIC__/Face/{$user.activityimg}" >

                    </if>
                    
                 </div>
          </div>
                  </div>   

          </div>
        
       
      



    </div>

<div class="am-margin">
    <button type="submit" class="am-btn am-btn-primary am-btn-xs">提交保存</button>
    <button type="reset" class="am-btn am-btn-primary am-btn-xs">放弃保存</button>
  </div>
  </form>


  </div>

  
</div>
<!-- content end -->


</div>



<footer>
  <hr>
  <p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed under MIT license.</p>
</footer>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/rem.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/respond.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.legacy.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="{:C('SUPPLIER_ADMIN_JS')}jquery.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.min.js"></script>
<!--<![endif]-->
<script src="{:C('SUPPLIER_ADMIN_JS')}app.js"></script>
<script type="text/javascript"charset="utf-8" src="{:C('SUPPLIER_ADMIN_JS')}umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="{:C('SUPPLIER_ADMIN_JS')}umeditor.min.js"></script>
<script type="text/javascript" src="{:C('SUPPLIER_ADMIN_JS')}lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
  function unique(){
    var name=$("input[name='theme']").val();
   jQuery.get('{:U("Activity/weiyi")}',
  {theme:name,},
  function(data){
  if(data.status===404){
    alert(data.info);
    $("input[name='themem']").val("").focus();
  }
 },'json');

   
  }
  function check(){
   var opentime=$("input[name='opentime']").val();
   var endtime=$("input[name='endtime']").val();
   if(opentime>endtime){
  alert("活动结束时间有误");
  $("input[name='opentime']").val("").focus();
  $("input[name='endtime']").val("").focus();
   }
  }


</script>
<script>
  /*$(function() {
    //$('.form-datetime').datetimepicker({format: 'yyyy-mm-dd hh:ii'});
    $('.form-datetime').datepicker({format: 'yyyy-mm'});
  });*/
</script>
<script>
var start = {
    elem: '#start',
    format: 'YYYY-MM-DD hh:mm:ss',
    min: laydate.now(), //设定最小日期为当前日期
    max: '2099-06-16 23:59:59', //最大日期
    istime: true,
    istoday: false,
    choose: function(datas){
         end.min = datas; //开始日选好后，重置结束日的最小日期
         end.start = datas //将结束日的初始值设定为开始日
    }
};
var end = {
    elem: '#end',
    format: 'YYYY-MM-DD hh:mm:ss',
    min: laydate.now(),
    max: '2099-06-16 23:59:59',
    istime: true,
    istoday: false,
    choose: function(datas){
        start.max = datas; //结束日选好后，重置开始日的最大日期
    }
};
laydate(start);
laydate(end);
</script>

<script>
;!function(){

//laydate.skin('molv');

laydate({
   elem: '#demo'
})

}();
</script>
<script type="text/javascript">
      //实例化编辑器
    var um = UM.getEditor('myEditor');
    um.addListener('blur',function(){
        $('#focush2').html('编辑器失去焦点了')
    });
    um.addListener('focus',function(){
        $('#focush2').html('')
    });
    //按钮的操作
</script>
</body>
</html>
<script type="text/javascript">

function ajaxFileUpload()//上传头像
   {
      $.ajaxFileUpload
         (
           {
                url:'{:U("Person/upface")}', //你处理上传文件的服务端
                secureuri:false,
                fileElementId:'fileup',
                dataType: 'json',
                success: function (data)
                      {
                        // alert(data);
                        // if(data.file_type==0){
                        //     alert(data.file_info);
                        // }else{
                        //     alert(data.file_type);
                        // }
                      }
                   }
             )

           return false;
     } 
</script>     
    
    
<script type="text/javascript">  
function previewImage(file)  //图片即时加载
{  
  var MAXWIDTH  = 150;  
  var MAXHEIGHT = 130;  
  var div = document.getElementById('preview');  
  if (file.files && file.files[0])  
  {  
    // div.innerHTML = '<img id=imghead>';  
    var img = document.getElementById('imghead');  
    img.onload = function(){  
      var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);  
      img.width = rect.width;  
      img.height = rect.height;  
      img.style.marginLeft = rect.left+'px';  
      img.style.marginTop = rect.top+'px';  
    }  
    var reader = new FileReader();  
    reader.onload = function(evt){img.src = evt.target.result;}  
    reader.readAsDataURL(file.files[0]);  
  }  
  else  
  {  
    var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';  
    file.select();  
    var src = document.selection.createRange().text;  
    // div.innerHTML = '<img id=imghead>';  
    var img = document.getElementById('imghead');  
    img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;  
    var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);  
    status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);  
    div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;margin-left:"+rect.left+"px;"+sFilter+src+"\"'></div>";  
  }  
}  
function clacImgZoomParam( maxWidth, maxHeight, width, height ){  
    var param = {top:0, left:0, width:width, height:height};  
    if( width>maxWidth || height>maxHeight )  
    {  
        rateWidth = width / maxWidth;  
        rateHeight = height / maxHeight;  
          
        if( rateWidth > rateHeight )  
        {  
            param.width =  maxWidth;  
            param.height = Math.round(height / rateWidth);  
        }else  
        {  
            param.width = Math.round(width / rateHeight);  
            param.height = maxHeight;  
        }  
    }  
      
    param.left = Math.round((maxWidth - param.width) / 2);  
    param.top = Math.round((maxHeight - param.height) / 2);  
    return param;  
}  
</script> 

